package com.itheima.listdemo;

import java.util.LinkedList;

public class LinkedListDemo2 {
    public static void main(String[] args) {
        LinkedList<String> linkedList = new LinkedList<>();
        linkedList.add("aaa");
        linkedList.add("bbb");
        linkedList.add("ccc");

//        method1(linkedList);
//        method2(linkedList);
//        method3(linkedList);
//        method4(linkedList);
        method5(linkedList);
    }

    private static void method5(LinkedList<String> linkedList) {
        String s = linkedList.removeLast();
        System.out.println(s);
        System.out.println(linkedList);
    }

    private static void method4(LinkedList<String> linkedList) {
        String s = linkedList.removeFirst();
        System.out.println(s);
        System.out.println(linkedList);
    }

    private static void method3(LinkedList<String> linkedList) {
        String first = linkedList.getFirst();
        String last = linkedList.getLast();
        System.out.println(first);
        System.out.println(last);
    }

    private static void method2(LinkedList<String> linkedList) {
        linkedList.addLast("www");
        System.out.println(linkedList);
    }

    private static void method1(LinkedList<String> linkedList) {
        linkedList.addFirst("qqq");
        System.out.println(linkedList);
    }
}
